using System.Linq;
using Sessionizer.Samples.Model;

namespace Sessionizer.Samples.Sessionized.TopBuilder
{
    public sealed class RankAggregator : IRankAggregator
    {
        private readonly IRankerProvider _rankerProvider;

        public RankAggregator(IRankerProvider rankerProvider)
        {
            _rankerProvider = rankerProvider;
        }

        public double GetRank(ITeam team)
        {
            return _rankerProvider.GetRankers().Select(ranker => (double) ranker.Rank(team)).Average();
        }
    }
}